package alan.springboot2x.sharejdbc.module.order.controller;


import alan.springboot2x.sharejdbc.module.order.entity.TOrder;
import alan.springboot2x.sharejdbc.module.order.service.impl.TOrderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 订单表 前端控制器
 * </p>
 *
 * @author alan
 * @since 2021-03-03
 */
@RestController
@RequestMapping("/order/t-order")
public class TOrderController {

    @Autowired
    TOrderServiceImpl tOrderService;

    @PostMapping("save")
    public String save(TOrder tOrder){
        boolean save = tOrderService.save(tOrder);
        return save + "";
    }

    @PostMapping("getByOrderId")
    public List<TOrder> getByOrderId(Long orderId){
        List<TOrder> tOrder = tOrderService.getByOrderId(orderId);
        return tOrder;
    }

    @PostMapping("getByUserId")
    public List<TOrder> getByUserId(Long userId){
        List<TOrder> tOrder = tOrderService.getByUserId(userId);
        return tOrder;
    }


    @PostMapping("getByUserIdAndOrderId")
    public List<TOrder> getByUserIdAndOrderId(Long userId, Long orderId){
        List<TOrder> tOrder = tOrderService.getByUserIdAndOrderId(userId,orderId);
        return tOrder;
    }

}

